package com.uniledger.commonlib.pinkeyboard;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.uniledger.commonlib.R;

import java.util.List;


public class PayThirdCompleteAdapter extends BaseAdapter {

    private List<PayThirdDesc> list;
    private Context context;
    private LayoutInflater inflater;

    public PayThirdCompleteAdapter(List<PayThirdDesc> list, Context context) {
        this.list = list;
        this.context = context;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public PayThirdDesc getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        VH vh;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_third_pay_desc, parent, false);
            vh = new VH(convertView);
            convertView.setTag(vh);
        } else {
            vh = (VH) convertView.getTag();
        }
        PayThirdDesc payDesc = getItem(position);
        vh.label.setText(payDesc.label);
        vh.desc.setText(payDesc.desc);
        return convertView;
    }

    static class VH {

        TextView label;

        TextView desc;

        public VH(View view) {
            label = (TextView) view.findViewById(R.id.txt_label);
            desc = (TextView) view.findViewById(R.id.txt_content);
        }
    }
}
